﻿<ui:VsDialogWindow
    x:Class="NuGet.Client.VisualStudio.UI.PreviewWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:resx="clr-namespace:NuGet.Client.VisualStudio.UI.Resources"
    xmlns:ui ="clr-namespace:NuGet.Client.VisualStudio.UI"
    x:Name="_self"
    ShowInTaskbar="False"
    WindowStyle="SingleBorderWindow"
    WindowStartupLocation="CenterOwner"
    Title="{Binding Title}"
    Height="500" Width="500">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <TextBlock
            Grid.Row="0"
            Margin="12,8,12,0"
            Text="{x:Static resx:Resources.Text_ReviewChanges}"
            FontSize="{Binding ElementName=_self,Path=FontSize,Converter={StaticResource Font122PercentSizeConverter}}" />

        <TextBlock
            Grid.Row="1"
            Margin="12,4,12,0"
            TextWrapping="Wrap"
            Text="{x:Static resx:Resources.Text_Changes}" />

        <Border
            Grid.Row="2"
            Margin="12,12"
            BorderBrush="{DynamicResource {x:Static resx:Brushes.BorderBrush}}"
            BorderThickness="1">
            <ScrollViewer
                HorizontalScrollBarVisibility="Auto"
                Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
                IsTabStop="True" >
                <ItemsControl
                    ItemsSource="{Binding Path=PreviewResults}"
                    IsTabStop="False">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="6, 6">
                                <TextBlock
                                    FontSize="{Binding ElementName=_self,Path=FontSize,Converter={StaticResource Font122PercentSizeConverter}}"
                                    Text="{Binding Path=Name}" />

                                <!-- Updated packages -->
                                <StackPanel Margin="0,8"
                                            Visibility="{Binding Path=Updated,Converter={StaticResource EnumerableToVisibilityConverter}}">
                                    <TextBlock
                                        FontWeight="Bold"
                                        Text="{x:Static resx:Resources.Label_UpdatedPackages}" />
                                    <ItemsControl
                                        Margin="10,0,0,0"
                                        ItemsSource="{Binding Path=Updated}"
                                        IsTabStop="False">
                                    </ItemsControl>
                                </StackPanel>

                                <!-- Installed packages -->
                                <StackPanel Margin="0,8"
                                            Visibility="{Binding Path=Added,Converter={StaticResource EnumerableToVisibilityConverter}}">
                                    <TextBlock
                        FontWeight="Bold"
                        Text="{x:Static resx:Resources.Label_InstalledPackages}" />
                                    <ItemsControl
                                        Margin="10,0,0,0"
                                        ItemsSource="{Binding Path=Added}"
                                        IsTabStop="False">
                                    </ItemsControl>
                                </StackPanel>

                                <!-- Uninstalled packages -->
                                <StackPanel Margin="0,8"
                                            Visibility="{Binding Path=Deleted,Converter={StaticResource EnumerableToVisibilityConverter}}">
                                    <TextBlock
                        FontWeight="Bold"
                        Text="{x:Static resx:Resources.Label_UninstalledPackages}" />
                                    <ItemsControl
                                        Margin="10,0,0,0"
                                        ItemsSource="{Binding Path=Deleted}"
                                        IsTabStop="False">
                                    </ItemsControl>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>
        </Border>

        <Grid Grid.Row="3" Background="{Binding ElementName=_self, Path=Background}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>
            <Button Grid.Column="1"
                    MinWidth="86"
                    MinHeight="24"
                    Margin="0,12"
                    AutomationProperties.AutomationId="OK"
                    Content="{x:Static resx:Resources.Button_OK}" Click="OkButtonClicked" />
            <Button Grid.Column="2"
                    MinWidth="86"
                    MinHeight="24"
                    Margin="6,12,12,12"
                    AutomationProperties.AutomationId="Cancel"
                    Content="{x:Static resx:Resources.Button_Cancel}" Click="CancelButtonClicked" />
        </Grid>
    </Grid>
</ui:VsDialogWindow>